/**
 * Created by python on 19-3-1.
 */
let app = new Vue({
    el:'#app',

    data:{
        HOST,
        user_id: sessionStorage.user_id || localStorage.user_id,
        token: sessionStorage.token || localStorage.token,
        avatar_url:sessionStorage.avatar_url || localStorage.avatar_url,
       //  info:{'id':'',
       //  'title':'',
       // 'create_time':'',
       //  'clicks':'',
       //  'pageviews':'',
       //  'answer_count':'',},
        info:[],
        server_time:'',
        hotlabel:[],



    },

    mounted:function () {
            this.get_question(1);
            axios.get(this.HOST+'/hotlabels/',{
                //向后端传递JWT token的方法
                headers:{
                    'Authorization':'JWT' + this.token
                },
                responseType:'json',
            })
                .then(response =>{
                    //加载页面数据

                    this.hotlabel = response.data;


                    })
            },

    methods:{
        get_question:function (id) {
            axios.get(this.HOST+'/questions/',{
                params:{
                  category_id:id
                },
                responseType:JSON
            })
                .then(response =>{
                    console.log(response.data);
                    this.info = response.data;
                    this.server_time = response.headers.date;
                })
        },


    },


});




